package oop.ex3.filemanager;

import java.io.File;
import java.util.List;

public class MyFileManagerTest {

	private MyFileManager fileManager;

	public MyFileManagerTest(MyFileManager myFileManager) {
		this.fileManager = myFileManager;
	}

	public void testDir() {
		List<File> fileList = fileManager.listFiles();
		if (fileList.size() != 5) {
			throw new RuntimeException("Test failed: dir didn't return 5 values.");
		}
	}

	public void testAdd() {
		String returnStatus = fileManager.add("m.txt");
		if (!returnStatus.equals("File already exists")) {
			throw new RuntimeException("Test failed: add should have said 'file already exists'.");
		}

		returnStatus = fileManager.add("goat");
		if (!returnStatus.startsWith("File Downloaded Successfully from")) {
			throw new RuntimeException("Test failed: add should have said 'File Downloaded Successfully'.");
		}
	}

	public static void main(String[] args) throws Exception {
		MyFileManagerTest tester = new MyFileManagerTest(new MyFileManager(new File("C:\\Java\\eclipse\\workspace\\oop.ex3\\serverlist1.txt"), new File("C:\\Java\\eclipse\\workspace\\oop.ex3\\mydir1"), 3000));

		tester.testDir();
		tester.testAdd();
	}

}
